// config/database.js
const mongoose = require("mongoose");

const connectDB = async () => {
  try {
    await mongoose.connect("mongodb://localhost:27017/imageDB",{  
      useNewUrlParser: true,  // 启用新解析器  
      useUnifiedTopology: true,
      useCreateIndex: true ,
   
    }); //例如:mongodb://localhost:27017/xxxx
    console.log("MongoDB 数据库连接成功");
  } catch (err) {
    console.error(err, "连接数据库失败");
  }
};

module.exports = connectDB;
